package com.yale.elasticsearch.controller.query;

import com.yale.elasticsearch.dto.TermQueryDTO;
import com.yale.elasticsearch.service.query.TermQueryService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.Valid;

/**
 * @author :yale
 * @date : 2024/8/1
 */
@Api(tags = "查询-精确查询")
@RestController
@RequestMapping("/query")
public class TermQueryController {

    @Resource
    private TermQueryService termQueryService;

    @ApiOperation(value = "精确查询", notes = "精确查询")
    @PostMapping("/term")
    public Object termQuery(@Valid @RequestBody TermQueryDTO termQueryDTO) {
        return termQueryService.termQuery(termQueryDTO);
    }

    @ApiOperation(value = "精确查询一个字段多个值", notes = "精确查询一个字段多个值")
    @PostMapping("/terms")
    public Object termsQuery(@Valid @RequestBody TermQueryDTO termQueryDTO) {
        return termQueryService.termsQuery(termQueryDTO);
    }

}
